package com.apanal.qlife.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 审核状态枚举类
 * @table: t_dictionary.AUDIT_STATUS
 * @author pan
 * @date 2017年4月11日
 * @version V1.0
 */
public enum AuditStatusEnum {

    /**
     * 收银员
     */
	REJECT("驳回", -1), 
    /**
     * 草稿
     */
	DRAFT("草稿", 0), 
	/**
	 * 待审核
	 */
	WAIT("待审核", 1), 
    /**
     * 通过
     */
	AGREE("通过", 2);

    private AuditStatusEnum(String desc, int value) {
        this.desc = desc;
        this.value = value;
    }

    /* 枚举值 */
    private int value;
    /* 描述 */
    private String desc;

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public int getValue() {
        return value;
    }

    public static AuditStatusEnum getEnum(int value) {
    	AuditStatusEnum resultEnum = null;
    	AuditStatusEnum[] enumAry = AuditStatusEnum.values();
        for (int i = 0; i < enumAry.length; i++) {
            if (enumAry[i].getValue() == value) {
                resultEnum = enumAry[i];
                break;
            }
        }
        return resultEnum;
    }

    public static List<Map<String, String>> toList() {
    	AuditStatusEnum[] ary = AuditStatusEnum.values();
        List<Map<String, String>> list = new ArrayList<>();
        for (int i = 0; i < ary.length; i++) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("value", String.valueOf(ary[i].getValue()));
            map.put("desc", ary[i].getDesc());
            list.add(map);
        }
        return list;
    }

    public static Map<String, Map<String, Object>> toMap() {
    	AuditStatusEnum[] ary = AuditStatusEnum.values();
        Map<String, Map<String, Object>> enumMap = new HashMap<String, Map<String, Object>>();
        for (int num = 0; num < ary.length; num++) {
            Map<String, Object> map = new HashMap<String, Object>();
            String key = String.valueOf(getEnum(ary[num].getValue()));
            map.put("value", String.valueOf(ary[num].getValue()));
            map.put("desc", ary[num].getDesc());
            enumMap.put(key, map);
        }
        return enumMap;
    }
}
